{$CLEO .s}
{$USE debug}
{$USE memory}
{$USE audio}
var 0@ : Integer
var 1@ : Integer
var 2@ : Integer
var 3@ : Integer
var 4@ : Integer
var 5@ : Integer
var 6@ : Integer
var 7@ : Integer
var 8@ : Integer
var 9@ : Integer
var 10@ : Integer

script_name "0AC2" // set_play_3d_audio_stream_at_coords
debug_on

trace "0AC2 (set_play_3d_audio_stream_at_coords)"


// load existing file
wait 0
if
    load_3d_audio_stream ".\Ding.mp3" store_to 0@
then
    trace "~g~~h~~h~0AC2 (set_play_3d_audio_stream_at_coords), #0 PASSED"
else
    breakpoint "~r~~h~~h~~h~0AC2 (set_play_3d_audio_stream_at_coords), #0 FAILED!~n~Failed to load file. Handle: %d" 0@
end


// test player's actor
wait 0
if
    does_char_exist $scplayer
then
    trace "~g~~h~~h~0AC2 (set_play_3d_audio_stream_at_coords), #1 PASSED"
else
    breakpoint "~r~~h~~h~~h~0AC2 (set_play_3d_audio_stream_at_coords), #1 FAILED!~n~Player character does not exists!" 0@
end


// get left coords
wait 0
get_offset_from_char_in_world_coords $scplayer offset -10.0 0.0 0.0 store_to 1@ 2@ 3@
trace "~g~~h~~h~0AC2 (set_play_3d_audio_stream_at_coords), #2 PASSED"


// set sound coordinates
wait 0
0AC2: set_play_3d_audio_stream_at_coords 0@ xyz 1@ 2@ 3@ // tested opcode
trace "~g~~h~~h~0AC2 (set_play_3d_audio_stream_at_coords), #3 PASSED"


// play the sound
wait 0
print_big_formatted "LEFT________________________" {time} 300 {style} TextStyle.MiddleSmaller
set_audio_stream_volume 0@ volume 10.0
set_audio_stream_state 0@ state AudioStreamAction.Play
wait 250
trace "~g~~h~~h~0AC2 (set_play_3d_audio_stream_at_coords), #4 PASSED"


// get right coords
wait 0
get_offset_from_char_in_world_coords $scplayer offset 10.0 0.0 0.0 store_to 1@ 2@ 3@
trace "~g~~h~~h~0AC2 (set_play_3d_audio_stream_at_coords), #2 PASSED"


// set sound coordinates
wait 0
0AC2: set_play_3d_audio_stream_at_coords 0@ xyz 1@ 2@ 3@ // tested opcode
trace "~g~~h~~h~0AC2 (set_play_3d_audio_stream_at_coords), #3 PASSED"


// play the sound
wait 0
print_big_formatted "________________________RIGHT" {time} 300 {style} TextStyle.MiddleSmaller
set_audio_stream_volume 0@ volume 10.0
set_audio_stream_state 0@ state AudioStreamAction.Play
wait 250
trace "~g~~h~~h~0AC2 (set_play_3d_audio_stream_at_coords), #4 PASSED"


terminate_this_custom_script
